package com.foosun.dao;

import java.util.List;

import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.stereotype.Component;

import com.foosun.entity.wechat.WxUser;

@Component
public class WxUserDao extends BaseDao<WxUser> {
	
	public WxUser findByOpenid(String openid) {
		String sql = "SELECT * FROM es_wxuser WHERE openid = ?";
		List<WxUser> list = this.getJdbcTemplate().query(sql, new BeanPropertyRowMapper<WxUser>(WxUser.class), new Object[]{openid});
		return (list == null || list.isEmpty() ? null : list.get(0));
	}
	
}
